package com.dog.basics.service.common.impl;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dog.basics.bean.dto.admin.common.SmsLogAddDto;
import com.dog.basics.bean.model.common.DogSmsLog;
import com.dog.basics.bean.vo.admin.common.SmsLogPageVo;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.dao.common.DogSmsLogMapper;
import com.dog.basics.service.common.IDogSmsLogService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 短信记录表 服务实现类
 * </p>
 *
 * @author guoy
 * @since 2020-03-23
 */
@Service
@AllArgsConstructor
public class DogSmsLogServiceImpl extends ServiceImpl<DogSmsLogMapper, DogSmsLog> implements IDogSmsLogService {
    private final DogSmsLogMapper dogSmsLogMapper;

    /**
     * @Description:  短信日志模块分页列表
     * @Param:  phone
     * @return:  IPage<SmsLogPageVo>
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @Override
    public IPage<SmsLogPageVo> getPageList(PageParam page, String phone) {
        return dogSmsLogMapper.getPageList(page, phone);
    }

    /**
     * @Description:  删除短信日志
     * @Param:  ids
     * @return:  Boolean
     * @Author: wph
     * @Date: 2020/3/27 0027
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean deleteObj(List<Long> ids) {
        return this.removeByIds(ids);
    }

    /**
     * 保存
     *
     * @param smsLogAddDto
     * @return
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Boolean saveObj(SmsLogAddDto smsLogAddDto) {
        DogSmsLog cljgSmsLog = new DogSmsLog();
        BeanUtil.copyProperties(smsLogAddDto, cljgSmsLog);
        return this.save(cljgSmsLog);
    }
}
